﻿// Copyright (c) SimpleIdServer. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using SimpleIdServer.Did.Crypto;
using SimpleIdServer.Did.Key;
using SimpleIdServer.WalletClient;
using System.Text.Json;

// var publicKey = GenerateDidKey();
var publicKey = "did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbrz1hh3CRY4pejtRCZ81CZj8PERW5ZtX2MxSEevzFx8knNYgxZm4emyBxZ8pyB2FipG8ciRVnWQeuRu7oJqfpkoQjqhsAzw5h8u5RPG6XEZSarcafMQumUrGtJc3twQRc9J";
var serializedPrivateKey = System.IO.File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "privatekey.json"));
var privateKey = SignatureKeySerializer.Deserialize(serializedPrivateKey);

// InTimeCredential();
// DeferredCredential();
// PreAuthorisedInTimeCredential();
// PreAuthorisedAndDeferredCredential();
VerifiablePresentationExchange();

void InTimeCredential()
{
    var intentData = "openid-credential-offer://?credential_offer_uri=https%3A%2F%2Fapi-conformance.ebsi.eu%2Fconformance%2Fv3%2Fissuer-mock%2Foffers%2Fffeb73a0-a951-4442-8439-7b51265437ee";
    var uri = Uri.TryCreate(intentData, UriKind.Absolute, out Uri r);
    var q = r.Query.TrimStart('?').Split('&').Select(t => t.Split('=')).ToDictionary(r => r[0], r => r[1]);
    var resolver = VerifiableCredentialOfferResolverFactory.Build();
    var vc = resolver.Resolve(q, publicKey, privateKey, CancellationToken.None).Result;
    Console.WriteLine(vc.Status);
}

void DeferredCredential()
{
    var intentData = "openid-credential-offer://?credential_offer_uri=https%3A%2F%2Fapi-conformance.ebsi.eu%2Fconformance%2Fv3%2Fissuer-mock%2Foffers%2F540d4b76-9399-410d-b79f-0de227b506ef";
    var uri = Uri.TryCreate(intentData, UriKind.Absolute, out Uri r);
    var q = r.Query.TrimStart('?').Split('&').Select(t => t.Split('=')).ToDictionary(r => r[0], r => r[1]);
    var resolver = VerifiableCredentialOfferResolverFactory.Build();
    var vc = resolver.Resolve(q, publicKey, privateKey, CancellationToken.None).Result;
    Thread.Sleep(6000);
    vc = vc.Retry(CancellationToken.None).Result;
    Console.WriteLine(vc.Status);
}

void PreAuthorisedInTimeCredential()
{
    const string pin = "6267";
    var intentData = "openid-credential-offer://?credential_offer_uri=https%3A%2F%2Fapi-conformance.ebsi.eu%2Fconformance%2Fv3%2Fissuer-mock%2Foffers%2F9f7626f4-d4d5-4932-b81f-658e2d7904e3";
    var uri = Uri.TryCreate(intentData, UriKind.Absolute, out Uri r);
    var q = r.Query.TrimStart('?').Split('&').Select(t => t.Split('=')).ToDictionary(r => r[0], r => r[1]);
    var resolver = VerifiableCredentialOfferResolverFactory.Build();
    var vc = resolver.Resolve(q, publicKey, privateKey, pin, CancellationToken.None).Result;
    Console.WriteLine(vc.Status);
}

void PreAuthorisedAndDeferredCredential()
{
    const string pin = "6267";
    var intentData = "openid-credential-offer://?credential_offer_uri=https%3A%2F%2Fapi-conformance.ebsi.eu%2Fconformance%2Fv3%2Fissuer-mock%2Foffers%2Fef87610b-f10e-444d-b5a6-17aed1286bcb";
    var uri = Uri.TryCreate(intentData, UriKind.Absolute, out Uri r);
    var q = r.Query.TrimStart('?').Split('&').Select(t => t.Split('=')).ToDictionary(r => r[0], r => r[1]);
    var resolver = VerifiableCredentialOfferResolverFactory.Build();
    var vc = resolver.Resolve(q, publicKey, privateKey, pin, CancellationToken.None).Result;
    Thread.Sleep(6000);
    vc = vc.Retry(CancellationToken.None).Result;
    Console.WriteLine(vc.Status);
}

void VerifiablePresentationExchange()
{
    var intentData = "\r\nopenid-credential-offer://?credential_offer_uri=https%3A%2F%2Fapi-conformance.ebsi.eu%2Fconformance%2Fv3%2Fissuer-mock%2Foffers%2F1ea6c23e-f10d-411c-a55e-5a0a24f0ffe0";
    var uri = Uri.TryCreate(intentData, UriKind.Absolute, out Uri r);
    var q = r.Query.TrimStart('?').Split('&').Select(t => t.Split('=')).ToDictionary(r => r[0], r => r[1]);
    var resolver = VerifiableCredentialOfferResolverFactory.Build(storedVcRecords: new List<StoredVcRecord>
    {
        new StoredVcRecord
        {
            Format = "jwt_vc",
            SerializedVc = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDplYnNpOnpqSFpqSjRTeTdyOTJCeFh6RkdzN3FEI1Q2aVBNVy1rOE80dXdaaWQyOUd3TGUtTmpnNDBFNmpOVDdoZExwSjNaU2cifQ.eyJpYXQiOjE3MjQ0NDE2NDgsImV4cCI6MTcyNDUyODA1MywianRpIjoidmM6ZWJzaTpjb25mb3JtYW5jZSNjNmMyZWVkMC05YWM5LTRhMTEtOGI0Yi00YmQxZWJiNWYyMzkiLCJzdWIiOiJkaWQ6a2V5OnoyZG16RDgxY2dQeDhWa2k3SmJ1dU1tRllyV1BnWW95dHlrVVozZXlxaHQxajlLYnJ6MWhoM0NSWTRwZWp0UkNaODFDWmo4UEVSVzVadFgyTXhTRWV2ekZ4OGtuTllneFptNGVteUJ4WjhweUIyRmlwRzhjaVJWbldRZXVSdTdvSnFmcGtvUWpxaHNBenc1aDh1NVJQRzZYRVpTYXJjYWZNUXVtVXJHdEpjM3R3UVJjOUoiLCJpc3MiOiJkaWQ6ZWJzaTp6akhaako0U3k3cjkyQnhYekZHczdxRCIsIm5iZiI6MTcyNDQ0MTY0OCwidmMiOnsiQGNvbnRleHQiOlsiaHR0cHM6Ly93d3cudzMub3JnLzIwMTgvY3JlZGVudGlhbHMvdjEiXSwiaWQiOiJ2YzplYnNpOmNvbmZvcm1hbmNlI2M2YzJlZWQwLTlhYzktNGExMS04YjRiLTRiZDFlYmI1ZjIzOSIsInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJWZXJpZmlhYmxlQXR0ZXN0YXRpb24iLCJDVFdhbGxldFNhbWVBdXRob3Jpc2VkSW5UaW1lIl0sImlzc3VlciI6ImRpZDplYnNpOnpqSFpqSjRTeTdyOTJCeFh6RkdzN3FEIiwiaXNzdWFuY2V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jOTUyYzhjODk3Y2ExZTYwNWZjZTI1ZjgyNjA0Yzc2YzE2ZDQ3OTc3MDAxNGI3YjI2MmI5M2MwMjUwIiwidHlwZSI6Iklzc3VhbmNlQ2VydGlmaWNhdGUifX19.4hf8Y0RgbO4ayYgtjwEzCc_F0iT0U7zQizpuFy1Vs-pI8CGaWsuqEK6ivnHT5uVCE7vR2uRuYu2wfjBsKJKf3A"
        }
    });
    var vc = resolver.Resolve(q, publicKey, privateKey, CancellationToken.None).Result;

}

string GenerateDidKey()
{
    var exportResult = DidKeyGenerator.New().GenerateRandomES256Key().Export(false, true);
    var export = SignatureKeySerializer.Serialize(exportResult.Key);
    File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "privatekey.json"), JsonSerializer.Serialize(export));
    return exportResult.Did;
}